﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ComparativeSheet
{
    public partial class IncorrcetForm : Form
    {
        public IncorrcetForm()
        {
            InitializeComponent();
        }

        private void IncorrcetForm_Load(object sender, EventArgs e)
        {
            //incorrectDocumentsTableAdapter.Fill(cSData.IncorrectDocuments);
            ComboBox cb = cbDepartments.ComboBox;
            cb.ValueMember = "Id";
            cb.DisplayMember = "Name";
            DataSets.CSDataTableAdapters.DepartmentsTableAdapter dAdapter = new ComparativeSheet.DataSets.CSDataTableAdapters.DepartmentsTableAdapter();
            DataSets.CSData.DepartmentsDataTable depts = dAdapter.GetData();
            cb.DataSource = depts;
        }

        private void cbDepartments_SelectedIndexChanged(object sender, EventArgs e)
        {
            Int32 dId = (Int32)cbDepartments.ComboBox.SelectedValue;
            incorrectDocumentsTableAdapter.Fill(cSData.IncorrectDocuments, dId);
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
                return;
            dataGridView1.Rows[e.RowIndex].Selected = true;
            DataRowView drv = dataGridView1.Rows[e.RowIndex].DataBoundItem as DataRowView;
            if (drv == null)
                return;
            DataSets.CSData.IncorrectDocumentsRow bdr = drv.Row as DataSets.CSData.IncorrectDocumentsRow;
            if (bdr == null)
                return;
            DocLineList dll = new DocLineList(bdr.Id);
            dll.ShowDialog();
        }
    }
}